package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domian.Analysis;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Administrator
 */
@Repository
public interface AnalysisMapper extends BaseMapper<Analysis> {

    @Select("select sum(num_registered) from  tb_analysis_by_day")
    Integer queryCumulativeUsers();

    //SELECT sum(num_active) FROM tb_analysis_by_day where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(record_date)
    @Select("SELECT * FROM tb_analysis_by_day where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(record_date)\n")
    List<Analysis> queryMonthActive();

    @Select("SELECT * FROM tb_analysis_by_day where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(record_date)")
    List<Analysis> queryWeekActive();


    //查询两个时间之中的用户数据
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date  between #{formatsd} and #{formated}\n")
    List<Analysis> queryRegistered(@Param("formatsd") String formatsd,@Param("formated") String formated);


}